import { request } from "@/utils/request";

export function getUserInfo() {
    return request({
        method: 'get',
        url: 'userInfo',
        headers: {
            'token': window.localStorage.token,
        },
    })
}

export function getBaseUserInfo() {
    return request({
        method: 'get',
        url: 'userInfo/baseInfo',
        headers: {
            'token': window.localStorage.token,
        },
    })
}

export function updateUserInfo(params) {
    return request({
        method: 'put',
        url: 'userInfo',
        data: params,
        headers: {
            'token': window.localStorage.token,
        },
    })
}

//根据用户id获取用户信息
export function getUserInfoById(id) {
    //将id拼接到url上面
    const encodedId = encodeURIComponent(id);
    const url = `/userInfo/GetBaseInfoByUserId?userId=${encodedId}`;

    return request({
        method: 'get',
        url: url,
        headers: {
            'token': window.localStorage.token,
        }
    })
}